package com.yiduo.outpost.core.security.jwt;

import io.jsonwebtoken.security.Keys;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.security.Key;
import java.time.Duration;

/**
 * @author yw
 */
@Data
@Component
@ConfigurationProperties(prefix = "yiye.agent.jwt")
public class JwtProperties {
    private Long expireDay = 1L;
    private Duration expireTime = Duration.ofDays(expireDay);
    private String secretKey = "C+4s3PJmqIbj/fuJD9Uwz428yBwl7ChmK3zKcVGRr5Hsn1Ln6UD/znkWZumdbQJFsiSe3Q3kijiLHBO1smoNkA==";

    private Key key;

    @PostConstruct
    public void init() {
        if (!StringUtils.isEmpty(secretKey)) {
            this.key = Keys.hmacShaKeyFor(secretKey.getBytes());
        }
    }


}
